home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MacApp / MacApp 3.0a2 / Libraries / FloatWindow.a < prev    next >
Encoding:
Text File  |  1991-05-01  |  47.3 KB  |  1,341 lines  |  [TEXT/MPS ]

  1. ;
  2. ;File PaletteWDEF.a
  3. ;--------------------------------------------------------------------------
  4. ;
  5. ;  Window Definition Routine for MacApp floaters
  6. ;
  7. ;  BUILD COMMANDS:
  8. ;
  9. ;    Asm "PaletteWDEF.a"
  10. ;    Link -rt WDEF=3 "PaletteWDEF.a.o" -o "Your File"
  11. ;
  12. ;
  13. ;    This file contains the window definition procedure "WindoidProc",
  14. ;    the "windoid" window type.  It is a rectangular window with a title bar.
  15. ;
  16. ;    3/14/90    Added to the MacApp sources from the HyperCard sources. Thanks to HyperCard team,
  17. ;    especially Kevin Calhoun.
  18.  
  19.             BLANKS        ON
  20.             STRING        ASIS
  21.             CASE        OFF
  22.  
  23.             PRINT        OFF
  24.             INCLUDE        'SysEqu.a'                                                ; <JKC 18May89>
  25.             INCLUDE        'QuickEqu.a'                                            ; <JKC 18May89>
  26.             INCLUDE        'Traps.a'                                                ; <JKC 18May89>
  27.             INCLUDE        'ToolEqu.a'                                                ; <JKC 18May89>
  28.             PRINT        ON
  29.             
  30. WDEF3        MAIN        EXPORT                                                    ; <JKC 18May89>
  31.  
  32. ;
  33. ;  FUNCTION   WindoidProc(selector: INTEGER;
  34. ;                          window: WindowPtr,
  35. ;                          message: INTEGER;
  36. ;                          parameter: LongInt): LongInt
  37.  
  38. LinkSize    EQU        -38
  39. ClpRgn        EQU        -38            ; our custom clip region
  40. IsColor        EQU        -34            ; do we have colorQD and toolbox?  [boolean]
  41. Align        EQU        -33            ; a dead byte for IsColor            
  42. SavBkCol    EQU        -32            ; saved wmgrCPort RGBBackColor     (color only)
  43. SavFgCol    EQU        -26            ; saved wmgrCPort RGBForeColor     (color only)
  44. AuxCPtr        EQU        -20            ; pointer to auxCTable            (color only)
  45. AuxCTab        EQU        -16            ; handle to auxCTable            (color only)
  46. TempRgn     EQU     -12         ; <18Oct85>
  47. WInfoRec    EQU     -8            ; <1Aug85>
  48. WAscent     EQU     -8            ; <1Aug85>
  49. WDescent    EQU     -6            ; <1Aug85>
  50. WHeight     EQU     -4            ; <1Aug85>
  51. WBoxDelta    EQU     -2            ; <1Aug85>
  52.  
  53. message        EQU        12            ;                                <C666/22Jan87> DAF
  54.  
  55. hasZoom     EQU     3            ; bit 3 is zoom bit             <EHB 29Aug85>
  56. hasGrow     EQU     2            ; bit 2 is grow bit             <EHB 29Aug85>
  57. hasTallTBar    EQU        1            ; bit 1 is tall title bar bit    <JKC 7Jan90>
  58. toggleTBar    EQU        0            ; bit 0 tells us whether to hilite/unhilite title bar    <JKC 7Jan90>
  59.  
  60. DocProc
  61.             BRA.S    DP1
  62.  
  63. ; standard header
  64.  
  65.             DC.W    0                    ; flags word
  66.             DC.B    'WDEF'                ; resource type
  67.             DC.W    3                    ; resource ID
  68.             DC.W    2                    ; version number
  69.  
  70. DP1
  71.             LINK    A6,#LinkSize         ; set up a stack frame to address parameters
  72.             MOVEM.L D2-D7/A1-A4,-(SP)    ; save work registers
  73.             
  74. ; test if the message is in range
  75.  
  76.             CMP.W    #wGIconMsg,message(A6)    ; compare to highest value            <C666/22Jan87> DAF
  77.             BGT     OORange                    ; skip it, it's too high            <C666/22Jan87> DAF
  78.             CMP.W    #wDrawMsg,message(A6)    ;  compare to lowest value, too        <C666/22Jan87> DAF
  79.             BMI     OORange                    ;                                    <C666/22Jan87> DAF
  80.             
  81.  
  82.             MOVE.L    (A5),A0             ; get pointer to quickDraw globals            <7Aug85>
  83.             MOVE.L    (A0),-(SP)            ; save current port on stack                <7Aug85>
  84.  
  85. ; Determine type of system.  We need to know if we have color QuickDraw and a color
  86. ;    window manager port.
  87.     
  88.             CMP.W    #$3FFF,ROM85        ; do we have color QD? 
  89.             SLS        IsColor(A6)            ; set boolean depending on color or B&W system
  90.             BHI.S    @BWSys                ; no, this system has B&W QD
  91.  
  92. ; when using the wmgrCPort, it is the defproc's responsibility to reconcile
  93. ;     the wmgrPort and the wmgrCPort.  
  94.  
  95.             BSR     UpdateCPort            ; compare and update wmgrPorts, also set WMgrCPort
  96.  
  97.             BRA.S    @CommonSys            ; 
  98. @BWSys            
  99.             MOVE.L    WMgrPort,-(SP)        ; and set port to window manager port
  100.             _SetPort                    ; 
  101. @CommonSys
  102.  
  103. ; get the font info for this font.    Put the height of the title bar in D7 and wHeight(A6).
  104. ; put the distance of the top of the goaway box from the top of the bar in WBoxDelta(A6).
  105.  
  106.             LEA     WInfoRec(A6),A3     ; point to our info rec                     <5Aug85>
  107.             MOVE.W    18(A6),D6            ; get variant code                            <JKC 31Jul89>
  108.              BTST    #hasTallTBar,D6     ; does it have tall title bar?                <JKC 31Jul89>
  109.             BNE.S    @1                    ; => if so, skip to tall tbar stuff            <JKC 31Jul89>
  110.             MOVEQ    #11,D7                ; fix title bar height at 11 pixels            <JKC 31Jul89>
  111.             MOVE.W    D7,wHeight(A6)        ; put title bar height here too                <JKC 31Jul89>
  112.             MOVE.W    #0,WBoxDelta(A6)    ; goAway delta is 2 pixels                    <JKC 31Jul89>
  113.             BRA.S    DoTempRgn            ; skip the tall title bar stuff                <JKC 31Jul89>
  114.             
  115. @1            MOVE.L    A3,-(SP)            ; push a pointer                            <5Aug85>
  116.             _GetFontInfo                ; and get the font's info                   <5Aug85>
  117.             MOVE.W    (A3)+,D7            ; (rect inset by 1 when WAscent used)        <5Aug85>
  118.             ADD.W    (A3)+,D7            ; add descent                                <5Aug85>
  119.             ADDQ.W    #4,D7                ; get the height                            <5Aug85>
  120.             BSET    #0,D7                ; make height odd for symmetry                <5Aug85>
  121.             MOVEQ    #19,D1                ; get 19                                    <26Aug85>
  122.             CMP.W    D1,D7                ; force height to 19 min                    <26Aug85>
  123.             BGE.S    @3                    ; => not a tiny font                        <5Aug85>
  124.             SUB.W    D7,D1                ; how much less than 19 is it?                <26Aug85>
  125.             LSR.W    #1,D1                ; used for centering tiny fonts             <26Aug85>
  126.             ADD.W    D1,WAscent(A6)        ; make the ascent "bigger"                    <26Aug85>
  127.             MOVEQ    #19,D7                ;                                            <5Aug85>
  128. @3            MOVE.W    D7,(A3)+            ; WHeight = ascent+descent+2                <5Aug85>
  129.             MOVE.W    D7,D0                ; get height                                <EHB 29Aug85>
  130.             SUB.W    #13,D0                ; subtract height of box                    <5Aug85>
  131.             LSR.W    #1,D0                ; divide by 2                                <5Aug85>
  132.             MOVE.W    D0,(A3)             ; save delta to goAway box                    <5Aug85>
  133.  
  134. DoTempRgn                                ; set up a temp region
  135.  
  136.             CLR.L    -(SP)                ; make room for result                        <EHB 18Oct85>
  137.             _NewRgn                     ; get a new region                            <EHB 18Oct85>
  138.             MOVE.L    (SP)+,TempRgn(A6)    ; and save in our frame                     <EHB 18Oct85>
  139.             CLR.L    -(SP)                ; make room for result                        <JKC 26Sep89>
  140.             _NewRgn                     ; get a new region                            <JKC 26Sep89>
  141.             MOVE.L    (SP)+,ClpRgn(A6)    ; and save in our frame                     <JKC 26Sep89>
  142.  
  143. ; save off the current port fore- & backcolors on color systems. 
  144.             
  145.             TST.B    IsColor(A6)            ; is it a color system?
  146.             BEQ.S    @NoColor1            ; nope, so skip this
  147.             
  148.             PEA        SavFgCol(A6)        ; push a pointer to save area
  149.             _GetForeColor                ; get the current color
  150.             PEA        SavBkCol(A6)        ; 
  151.             _GetBackColor                ;
  152.  
  153. ; also, find the auxWinRec and lock it down
  154.             
  155.             CLR.L    -(SP)                ; here's a space for the var handle
  156.             CLR.W    -(SP)                ; function return here
  157.             MOVE.L    14(A6),-(SP)        ; push window ptr 
  158.             PEA        6(SP)                ; a pointer to the space above
  159.             _GetAuxWin                    ; find the auxrec
  160.             ADDQ    #2,SP                ; pitch the boolean (it doesn't matter)
  161.             MOVE.L    (SP)+,A0            ; get the auxRecHandle
  162.             MOVE.L    (A0),A0                ; handle -> ptr
  163.             MOVE.L    awCTable(A0),A0    ; get the colortable handle                        <JKC 18May89>
  164.             MOVE.L    A0,AuxCTab(A6)        ; save this handle
  165.             _HLock                        ; lock the table down in memory
  166.             MOVE.L    (A0),AuxCPtr(A6)    ; and get a pointer too!
  167.  
  168. @NoColor1                                ; END OF A COLOR-ONLY SECTION
  169.  
  170. ; fetch the parameters into registers
  171.  
  172.             LEA     8(A6),A0            ; get ptr to first parameter
  173.             MOVE.L    (A0)+,D3            ; get param in D3
  174.             MOVE.W    (A0)+,D0            ; get message
  175.             MOVE.L    (A0)+,A3            ; get the window pointer
  176.             MOVE.W    (A0)+,D5            ; get the selector integer
  177.             MOVE    D5,D6                ; keep copy in D6
  178.             AND     #3,D5                ; ignore "inGrow" variant
  179.             CLR.L    (A0)                ; clear out function result
  180.  
  181. ; case out on the message number
  182.  
  183.             ADD     D0,D0                ; double for word index
  184.             LEA     GoDocProc,A0        ; get jump table address
  185.             ADD.W    GODOCPROC(D0),A0    ; compute dispatch address
  186.             JSR     (A0)
  187.  
  188. ; we're done -- restore registers and return to caller
  189.  
  190.             MOVE.L    TempRgn(A6),-(SP)    ; dispose of temp region            <EHB 18Oct85>
  191.             _DisposRgn                    ;                                    <EHB 18Oct85>
  192.             MOVE.L    ClpRgn(A6),-(SP)    ; dispose of clip region            <JKC 26Sep89>
  193.             _DisposRgn                    ;                                    <JKC 26Sep89>
  194.  
  195.             TST.B    IsColor(A6)            ; are we on a color system?            
  196.             BEQ.S    @NoColor2            ; if on B&W, then skip            
  197.             
  198.             MOVE.L    AuxCTab(A6),A0        ; get the colortable handle    <DAF 15-Apr-86>
  199.             _HUnlock                    ; release it                <DAF 15-Apr-86>
  200.             
  201. ; restore the fore- and backColors                                    <C203/08Oct86> DAF
  202.             PEA        savBkCol(A6)        ; pointer to RGBColor
  203.             _RGBBackColor                ;
  204.             PEA        savFgCol(A6)        ; pointer to RGBColor
  205.             _RGBForeColor                ;
  206.  
  207. @NoColor2                                ; END OF A COLOR-ONLY SECTION
  208.  
  209.             _SetPort                    ; the old port is on top of stack    <EHB 7Aug85>
  210. OORange                                    ; 'Out Of Range, of course'            <C666/22Jan87> DAF
  211.             MOVEM.L (SP)+,D2-D7/A1-A4    ; restore work registers
  212.             UNLK    A6                    ; unlink stack frame
  213.             MOVE.L    (SP)+,A0            ; get return address
  214.             ADD     #12,SP                ; strip parameters
  215.             JMP     (A0)                ; return to caller
  216.  
  217. ; DocumentProc dispatch table -- entries must be long branches!
  218.  
  219. GODOCPROC
  220.             DC.W    DrawDoc-GoDocProc    ; draw is message #0
  221.             DC.W    HitDoc-GoDocProc    ; hit test is message #1
  222.             DC.W    CalcDoc-GoDocProc    ; calc test is message #2
  223.             DC.W    InitDoc-GoDocProc    ; init is message #3
  224.             DC.W    DisposeDoc-GoDocProc   ; dispose is message #4
  225.             DC.W    GrowDoc-GoDocProc    ; grow message is #5
  226.             DC.W    DrawGIcon-GoDocProc ; draw grow icon is #6
  227.  
  228.  
  229. ; utility UpdateCPort 
  230. ;    This utility compares the pertinent fields of the wmgrPort and the wmgrCPort,
  231. ;    updating the wmgrCPort as necessary to match the wmgrPort.
  232.  
  233. UpdateCPort                                ; <C666/22Jan87> DAF    
  234.             MOVE.L    WmgrCPort,-(SP)        ; make the wmgrCPort the current port
  235.             _SetPort                    ; set it
  236.  
  237.             MOVE.L    WmgrPort,A0            ; get the wmgrPort addr
  238.             MOVE.L    WmgrCPort,A1        ; and the wmgrCPort too
  239.             
  240.             PEA        bkPat(A0)            ; push pointers to pattern for later
  241.             PEA        pnPat(A0)            ;
  242.  
  243. ; copy all fields from pnLoc to end of grafPort, excluding pnPixPat and fillPixPat
  244.  
  245.             LEA        pnLoc(A0),A0                    ; point at source
  246.             LEA        pnLoc(A1),A1                    ; point at dest
  247.             MOVE.L    (A0)+,(A1)+                        ; copy pnLoc
  248.             MOVE.L    (A0)+,(A1)+                        ; copy pnSize
  249.             MOVE.W    (A0)+,(A1)+                        ; copy pnMode
  250.             ADDQ    #8,A0                            ; skip pnPat (aka, pnPixPat,fillPixPat)
  251.             ADDQ    #8,A1                            ; 
  252.             MOVE.W    #((portRec-pnVis)/2)-1,D0        ; set up a counter (long sized)
  253. @1
  254.             MOVE.W    (A0)+,(A1)+                        ; copy it
  255.             DBRA    D0,@1                            ; loop
  256.             
  257. ; now set up the patterns in the wmgrCPort (which is thePort)
  258. ;    the parameters were pushed before the copying loop above
  259.  
  260.             _PenPat
  261.             _BackPat
  262.  
  263.             RTS                            ; <C666/22Jan87> DAF
  264.  
  265. ; InitDoc is used to initialize our zoom size
  266.  
  267. InitDoc     BTST    #hasZoom,D6         ; does it want a zoom box?        <EHB 29Aug85>
  268.             BEQ.S    noZoom                ; => nope, no zoom                <EHB 29Aug85>
  269.             CLR.B    wZoom(A3)            ; assume no zoom box            <EHB 29Aug85>
  270.             TST.W    ROM85                ; running on new roms?            <EHB 18Oct85>
  271.             BMI.S    noZoom                ; => no, use default            <EHB 18Oct85>
  272.             MOVEQ    #16,D0                ; space for 2 rects             <EHB 29Aug85>
  273.             _NewHandle ,CLEAR            ; allocate the space            <EHB 29Aug85>
  274.             BNE.S    noZoom                ; => not able to get space        <EHB 29Aug85>
  275.  
  276. ; set default zoom data.  Consists of 2 fields:  SmallSize, BigSize: Rect
  277.  
  278.             ADDQ.B    #1,wZoom(A3)        ; set zoom flag to TRUE         <EHB 29Aug85>
  279.             MOVE.L    A0,WDataHandle(A3)    ; save handle to data            <EHB 29Aug85>
  280.             MOVE.L    (A0),A4             ; point to data                 <EHB 29Aug85>
  281.             ADDQ.W    #8,A4                ; point to bigSize                <EHB 29Aug85>
  282.  
  283. ; get the size of the zoomed out window in global coordinates.    To do this,
  284. ; pull the screen size from screenbits.bounds and indent a little.
  285.  
  286.             MOVE.L    GrafGlobals(A5),A1    ; point to QuickDraw globals    <EHB 29Aug85>
  287.             MOVE.L    Screenbits+Bounds(A1),(A4)+     ; get topLeft        <EHB 29Aug85>
  288.             MOVE.L    Screenbits+Bounds+4(A1),(A4)+    ; get botRight        <EHB 29Aug85>
  289.             MOVEQ    #3,D0                            ; get indent        <EHB 29Aug85>
  290.             SUB.W    D0,-(A4)            ; indent right                    <EHB 29Aug85>
  291.             SUB.W    D0,-(A4)            ; indent bottom                 <EHB 29Aug85>
  292.             ADD.W    D0,-(A4)            ; indent left                    <EHB 29Aug85>
  293.             ADD.W    D0,-(A4)            ; indent top                    <EHB 29Aug85>
  294.             MOVE.W    MBarHeight,D0        ; get menubar height             <JKC 31Jul89>
  295.             ADD.W    D0,(A4)             ; past menu bar                 <JKC 31Jul89>
  296.             ADD.W    D7,(A4)             ; and past window title         <EHB 29Aug85>
  297.  
  298.             MOVE.L    (A0),A4             ; A4 = smallsize                <EHB 29Aug85>
  299.  
  300. ; get current size into rect in A4
  301.  
  302. GetRect     MOVE.L    A4,-(SP)            ; push address of rect            <EHB 29Aug85>
  303.             MOVE.L    PortRect(A3),(A4)    ; get topLeft (local)            <EHB 29Aug85>
  304.             MOVE.L    PortRect+4(A3),4(A4)    ; get botRight (local)        <EHB 29Aug85>
  305.             MOVE.L    A3,A0                ; copy portPtr for PortToMap    <C424/18Nov86> DAF
  306.             BSR        PortToMap            ; get the rect pointer            <C424/18Nov86> DAF
  307.             MOVE.L    Bounds(A0),-(SP)    ; push offset locToGlob         <EHB 29Aug85>
  308.             NEG.W    (SP)                    ; make offset positive        <EHB 29Aug85>
  309.             NEG.W    2(SP)
  310.             _OffsetRect                 ; convert rect to global
  311. NoZoom        RTS
  312.  
  313. ; IsItSmall returns NE if the window has been resized or moved (NE if window "small")
  314. ; It updates smallsize if it has.  (If tab, only move small window).
  315. ;            Trashes A0,A1,A4
  316.  
  317. IsItSmall    SUBQ    #8,SP                ; make room for a rect            <EHB 29Aug85>
  318.             MOVE.L    SP,A4                ; point to it                    <EHB 29Aug85>
  319.             BSR.S    GetRect             ; A4 = curSize                    <EHB 29Aug85>
  320.             MOVE.L    wDataHandle(A3),A0    ; get data handle                <EHB 29Aug85>
  321.             MOVE.L    (A0),A2             ; A2 = bigSize                    <EHB 29Aug85>
  322.             ADDQ    #8,A2
  323.  
  324. ; the window is large if all corners are within 7 of their default positions
  325.  
  326.             BSR.S    ChkPoint            ; compare topleft                <EHB 18Sep85>
  327.             BNE.S    IsSmall             ; => not close enough            <EHB 29Aug85>
  328.             BSR.S    ChkPoint            ; compare botright                <EHB 18Sep85>
  329.             BEQ.S    NotSmall            ; => it's close enough          <EHB 29Aug85>
  330. IsSmall     MOVE.L    wDataHandle(A3),A0    ; get data handle                <EHB 29Aug85>
  331.             MOVE.L    (A0),A4             ; save window's current size    <EHB 29Aug85>
  332.             BSR.S    GetRect             ; get current size into A4        <EHB 29Aug85>
  333. SaySmall    MOVEQ    #1,D0                ; return NE!                    <EHB 29Aug85>
  334. NotSmall    ADDQ    #8,SP                ; strip rect from stack         <EHB 29Aug85>
  335.             RTS
  336.  
  337. ChkPoint    MOVE.L    (A2),-(SP)            ; make point into a rect        <EHB 18Sep85>
  338.             MOVE.L    (A2)+,-(SP)         ; by pushing twice                <EHB 18Sep85>
  339.             MOVE.L    SP,-(SP)            ; and insetting by 7            <EHB 18Sep85>
  340.             MOVE.L    #$FFF9FFF9,-(SP)    ;                                <EHB 18Sep85>
  341.             _InsetRect                    ;                                <EHB 18Sep85>
  342.             CLR.W    -(SP)                ; is cursize within 7 of        <EHB 18Sep85>
  343.             MOVE.L    (A4)+,-(SP)         ; that point?                    <EHB 18Sep85>
  344.             PEA     6(SP)                ;                                <EHB 18Sep85>
  345.             _PtInRect                    ;                                <EHB 18Sep85>
  346.             SUBQ.B    #1,(SP)             ; reverse sign of result        <EHB 18Sep85>
  347.             MOVE.B    (SP)+,D0            ;                                <EHB 18Sep85>
  348.             ADDQ    #8,SP                ; strip off the rect            <EHB 18Sep85>
  349.             RTS                         ; exit w/EQ if "Big"            <EHB 18Sep85>
  350.  
  351. ; IsThereZoom returns EQ if zoom not enabled
  352.  
  353. IsThereZoom BTST    #hasZoom,D6         ; zooming variant                <EHB 29Aug85>
  354.             BEQ.S     IsNoZoom            ; => no                         <EHB 29Aug85>
  355.             TST.B    wZoom(A3)            ; did we get the handle?        <EHB 29Aug85>
  356. IsNoZoom    RTS                         ; EQ if no Zoom                 <EHB 29Aug85>
  357.  
  358.  
  359.  
  360. ; DisposeDoc is called when the window is being closed.  All we need to do is
  361. ; give back the handle we borrowed.
  362.  
  363. DisposeDoc    BSR.S    IsThereZoom         ; is there a zoom box?            <EHB 29Aug85>
  364.             BEQ.S    InDisposed            ; => no, we're done             <EHB 29Aug85>
  365.             MOVE.L    wDataHandle(A3),A0    ; get handle to our data        <EHB 29Aug85>
  366.             _DisposHandle                ; release it, ignoring errors    <EHB 29Aug85>
  367. InDisposed    RTS
  368.  
  369.  
  370.  
  371. ; SetUpColor takes a window part identifier in D0, finds the corresponding
  372. ;    part in the AuxWinTable (the part code is in the .value field) and returns
  373. ;    a pointer to its RGB on the stack.  If the requested part is not found,
  374. ;    the first color table element is used (I'd use frameColor, but that might
  375. ;    not be there!).  Trashes A0/D0.        ; rewritten <C177/25Sep86> DAF
  376.  
  377. SetUpColor
  378.             MOVE.L    D1,-(SP)            ; save a register
  379.             MOVE.L    AuxCPtr(A6),A0        ; get the color table pointer
  380.             MOVE.W    CTSize(A0),D1        ; get the color table size
  381.             MULU    #8,D1                ; convert to color table index
  382. LegalIndex    
  383.             CMP.W    CTTable+value(A0,D1),D0    ; is this the one?
  384.             BEQ.S    FoundIt                ; if equal, then done
  385.             SUB.W    #8,D1                ; try the previous one
  386.             BGE.S    LegalIndex            ; loop while index positive
  387.             MOVEQ    #0,D1                ; OK, use the first one
  388. FoundIt        
  389.             LEA        CTTable+rgb(A0,D1),A0 ; get the address of the color to use
  390.             MOVE.L    A0,D0                ; we'll need A0 in a second
  391.             MOVE.L    (SP)+,D1            ; restore the register
  392.             MOVE.L    (SP)+,A0            ; get the return address
  393.             MOVE.L    D0,-(SP)            ; push the rgb addr on the stack
  394.             JMP        (A0)                ; return to caller
  395.             
  396.  
  397. PORTTOMAP                                        ; <C424/18Nov86> DAF
  398. ;----------------------------------------------------------
  399. ;
  400. ; Given a window pointer in A0, return the bitmap/pixmap pointer in A0
  401.  
  402.             ADDQ    #PORTBITS,A0                ;POINT TO BITMAP/PIXMAP HANDLE
  403.             TST        ROWBYTES(A0)                ;BITMAP OR PIXMAP HANDLE?
  404.             BPL.S    GOTBITMAP                    ;=>JUST A BITMAP
  405.             MOVE.L    BASEADDR(A0),A0                ;ELSE GET PORT'S PIXMAP HANDLE
  406.             MOVE.L    (A0),A0                        ;GET PIXMAP POINTER
  407. GOTBITMAP    RTS
  408.  
  409.                         
  410.             
  411. ;  DrawDoc -- draw the document window.   The windowPtr is in A3
  412.  
  413. DrawDoc
  414.             TST.B    WVISIBLE(A3)        ; is it visible?
  415.             BEQ     DoneDoc             ; if not, don't do anything
  416.  
  417. ; see if its a EORGoAway call and special case it
  418.  
  419.             CMP     #wInGoAway,D3        ; is it a goAway call?
  420.             BGE     EorStuff            ; if so, go handle it                <EHB 29Aug85>
  421.  
  422.             _PenNormal                    ; we want the normal pen
  423.  
  424. ; derive the titleBar rectangle from the structRgn and keep it in TempRect
  425.  
  426.             BSR     BuildTBarRect
  427.  
  428. ; draw the title bar
  429.  
  430.             TST.B    IsColor(A6)            ; is it color?            
  431.             BEQ.S    @NoColor3            ; no, so skip this
  432.             
  433.             MOVE.W    #wFrameColor,D0        ; color to set                    <C203/08Oct86> DAF
  434.             BSR.S    SetUpColor            ; set it up                        <C203/08Oct86> DAF
  435.             _RGBForeColor                ;                                 <C203/08Oct86> DAF
  436.             
  437.             MOVE.W    #wTitleBarColor,D0     ;                                  <C203/08Oct86> DAF
  438.             BSR.S    SetUpColor            ;                                 <C203/08Oct86> DAF
  439.             _RGBBackColor                ;                                 <C203/08Oct86> DAF
  440.             
  441. @NoColor3                                ; END OF A COLOR-ONLY SECTION
  442.  
  443.             PEA     TEMPRECT            ; tempRect bounds the title bar
  444.             MOVE.L    (SP),-(SP)            ; make another copy of tempRect pointer
  445.             BTST    #toggleTBar,D6         ; should we toggle the title bar?    <JKC 20Sep89>
  446.             BEQ.S    @1                    ; no, don't erase title bar            <JKC 17Aug89>
  447.             TST.B    wHilited(A3)        ; is it hilited?
  448.             BNE.S     @1                    ; yes, don't erase title bar
  449.             MOVE.L    (SP),-(SP)            ; copy for InsetRect                <JKC 17Aug89>
  450.             _EraseRect                    ; erase it                            <JKC 17Aug89>
  451. @1            _FrameRect                    ; frame the title bar
  452.             MOVE.L    OneOne,-(SP)        ; push inset factor
  453.             _InsetRect
  454.             
  455.              BTST    #hasTallTBar,D6     ; does it have tall title bar?        <JKC 31Jul89>
  456.             BEQ.S    CheckHilite            ; => no, don't draw title string    <JKC 31Jul89>
  457.             BSR     DoTitleString        ; draw the centered Title
  458.  
  459. ; To prevent title flicker, DoTitleString returns the left edge of the
  460. ; title in D3 and the right edge in D4.  If the title bar needs to be
  461. ; highlighted, the highlighting is done in 2 sections, one on each side
  462. ; of the title.
  463.  
  464. CheckHilite
  465.             BTST    #toggleTBar,D6         ; pay attention to the hilite state?    <JKC 20Sep89>
  466.             BEQ.S    DoHilite            ; no, do hilite no matter what            <JKC 20Sep89>
  467.             TST.B    wHilited(A3)        ; is it hilited?
  468.             BEQ     DrawBody            ; => go draw the frame
  469.  
  470. DoHilite    
  471.             TST.B    IsColor(A6)            ; is it color?            
  472.             BEQ.S    @NoColor4            ; no, so skip this
  473.             
  474.             MOVE.W    #wTitleBarColor,D0    ; set up colors                        <C203/08Oct86> DAF
  475.             BSR     SetUpColor            ;
  476.             _RGBBackColor                ;
  477.             
  478.             MOVE.W    #wHiliteColor,D0    ;
  479.             BSR     SetUpColor            ;
  480.             _RGBForeColor                ;                                    <C203/08Oct86> DAF
  481. @NoColor4                                ; END OF A COLOR-ONLY SECTION
  482.  
  483.              BTST    #hasTallTBar,D6     ; does it have tall title bar?        <JKC 31Jul89>
  484.             BEQ.S    @2                    ; => no, fill entire title bar        <JKC 31Jul89>
  485.  
  486.             MOVE.W    TempRect+Right,-(SP)    ; save right of TempRect
  487.             MOVE.W    D3,TempRect+Right        ; new right = title left
  488.  
  489. ; used A4 instead of A0 to save a couple o'bytes (EHB)
  490.  
  491. @2            MOVE.L    TempRect,D0         ; get topLeft
  492.             AND.L    #$00070007,D0        ; only use mod 8
  493.             MOVE.L    (A5),A4             ; get globals, save in A4
  494.             MOVE.L    D0,PatAlign(A4)     ; set up patAlign
  495.             PEA     TempRect            ; fill this rect
  496.              BTST    #hasTallTBar,D6     ; does it have tall title bar?        <stm 16oct89>
  497.             BEQ.S    @7                    ; => no, use regular pat            <stm 16oct89>
  498.             PEA     AltHilitePattern    ; => yes, use alternate pat            <stm 16oct89>
  499.             BRA.S    @6                    ;                                    <stm 16oct89>
  500. @7            PEA     HilitePattern        ; push the pattern address
  501. @6            _FillRect                    ; fill with the pattern
  502.  
  503.              BTST    #hasTallTBar,D6     ; does it have tall title bar?        <JKC 31Jul89>
  504.             BEQ.S    ClrPatAln            ; => no, draw the go away button    <JKC 31Jul89>
  505.  
  506.             BSR      IsThereZoom         ; is zooming allowed? (was .S)        <EHB 18-Oct-85>
  507.             BEQ.S    @1                    ; => no, use current d4             <EHB 18-Oct-85>
  508.             MOVE.W    (SP),D0             ; else get right edge of box        <EHB 18-Oct-85>
  509.             SUB.W    #26,D0                ; how much room is there?            <EHB 18-Oct-85>
  510.             CMP.W    D4,D0                ; need at least 26 pixels            <EHB 18-Oct-85>
  511.             BGE.S    @1                    ; => got 'em, use current d4        <EHB 18-Oct-85>
  512.             MOVE.W    D0,D4                ; else use right-26                 <EHB 18-Oct-85>
  513.  
  514. @1            MOVE.W    (SP)+,TempRect+Right    ; restore right of title box
  515.             MOVE.W    D4,TempRect+Left    ; set new left of title box
  516.             PEA     TempRect            ; fill this rect
  517.             PEA     HilitePattern        ; push the pattern address
  518.             MOVE.W    TempRect+top,D0        ; get top                            <stm 16oct89>
  519.             SWAP    D0                    ; into high word                    <stm 16oct89>
  520.             MOVE.W    TempRect+right,D0    ; get right into low word            <stm 16oct89>
  521.             AND.L    #$00070007,D0        ; only use mod 8                    <stm 16oct89>
  522.             MOVE.L    D0,PatAlign(A4)     ; set up patAlign                    <stm 16oct89>
  523.             _FillRect
  524.  
  525. ClrPatAln    CLR.L    PatAlign(A4)
  526.  
  527. ; plot the goAway button
  528.  
  529. DoGoAway
  530.             TST.B    WGoAway(A3)         ; is there a goaway button?
  531.             BEQ.S    DoZoom                ; => if not, try for zoom        <EHB 29Aug85>
  532.  
  533.              BTST    #hasTallTBar,D6     ; does it have tall title bar?    <JKC 31Jul89>
  534.             BNE.S    @3                    ; => yes, plot big go away        <JKC 31Jul89>
  535.             BSR        DrawSmallGoAway        ; plot small go away box        <JKC 31Jul89>
  536.             BRA.S    DoZoom                ; skip big go away                <JKC 31Jul89>
  537.  
  538. @3            BSR     BuildTBarRect
  539.             LEA     GoAwayData,A1        ; get the goAway symbol
  540.             MOVEQ    #srcCopy,D0         ; plot in srcCopy mode            <EHB 29Aug85>
  541.             BSR     PlotGoAway
  542.  
  543. DoZoom        BSR     IsThereZoom         ; is there a zoom box?            <EHB 29Aug85>
  544.             BEQ.S    DrawBody            ; => no, draw window frame        <EHB 29Aug85>
  545.  
  546.             BSR.S     BuildTBarRect        ; build a title bar rect        <EHB 29Aug85>
  547.             
  548.              BTST    #hasTallTBar,D6     ; does it have tall title bar?    <JKC 31Jul89>
  549.             BNE.S    @4                    ; => yes, plot big zoom box        <JKC 31Jul89>
  550.             BSR        DrawSmallZoom        ; plot small zoom box            <JKC 31Jul89>
  551.             BRA.S    DrawBody            ; small title bar                <JKC 31Jul89>
  552.  
  553. @4            MOVE.W    TempRect+Right,D0    ;                                <JKC 25May89>
  554.             MOVE.W    TempRect+Left,D4    ;                                <JKC 25May89>
  555.             SUB.W    D4,D0                ;                                <JKC 25May89>
  556.  
  557.             LEA     ZoomData,A1         ; get the zoom data             <stm 16oct89>
  558.             MOVEQ    #srcCopy,D0         ; plot in srcCopy mode            <EHB 29Aug85>
  559.             BSR     PlotZoom            ; and plot the symbol            <EHB 29Aug85>
  560.  
  561. DrawBody    MOVE.L    OneOne,D4            ; constant for shadowing
  562.  
  563. ; frame the body of the window
  564.  
  565. DrawFrame
  566.             TST.B    IsColor(A6)            ; is it color?
  567.             BEQ.S    @NoColor5            ; no, so skip this section
  568.             
  569.             MOVE.L    #wFrameColor,D0        ; set up colors <C203/08Oct86> DAF
  570.             BSR        SetUpColor            ;                 <C203/08Oct86> DAF
  571.             _RGBForeColor                ;                 <C203/08Oct86> DAF
  572.             MOVE.L    #wContentColor,D0    ; set up background too for variant 1     <CXXX/21Jan87> DAF
  573.             BSR        SetUpColor            ;                                         <CXXX/21Jan87> DAF
  574.             _RGBBackColor                ;                                         <CXXX/21Jan87> DAF
  575. @NoColor5                                ; END OF A COLOR-ONLY SECTION
  576.  
  577.             MOVE.L    STRUCTRGN(A3),A0    ; get region handle
  578.             MOVE.L    (A0),A0             ; get region ptr
  579.             LEA     RGNBBOX(A0),A4        ; point A4 at the bounding box
  580.             SUB     D4,Bottom(A4)        ; inset the bottom (ignore shadow)
  581.             SUB     D4,Right(A4)        ; inset the right to ignore shadow
  582.             MOVE.L    A4,-(SP)            ; push bounding box
  583.             _FrameRect                    ; frame the body
  584.  
  585. ; draw the drop shadow
  586.  
  587.             BSR     PaintDropShadow     ; paint the drop shadow
  588.  
  589.             MOVE.L    STRUCTRGN(A3),A4    ; get region handle again, for safety    <S369/25Jan88> DAF
  590.             MOVE.L    (A4),A4             ; get region ptr                        <S369/25Jan88> DAF
  591.             LEA     RGNBBOX(A4),A4        ; point A4 at the bounding box            <S369/25Jan88> DAF
  592.             
  593.             ADD     D4,Bottom(A4)
  594.             ADD     D4,Right(A4)
  595. DoneDoc
  596.             RTS
  597.  
  598. HilitePattern                            ;                                <JKC 25May89>
  599.             DC.W    $00AA,$00AA,$00AA,$00AA
  600.             
  601. AltHilitePattern                        ;                                    <JKC 25May89>
  602.             DC.W    $0055,$0055,$0055,$0055
  603.             
  604.  
  605. ; BuildTBarRect builds a rectangle enclosing the titleBar in TempRect
  606.  
  607. BuildTBarRect
  608.             LEA     TEMPRECT,A0         ; get pointer to tempRect
  609.             MOVE.L    STRUCTRGN(A3),A1    ; get structure region handle
  610.             MOVE.L    (A1),A1             ; get strucRgn pointer
  611.             ADDQ    #RGNBBOX,A1         ; point A1 at the bounding box
  612.             MOVE.L    (A1)+,(A0)            ; copy bounding box into tempRect
  613.             MOVE.L    (A1),4(A0)
  614.  
  615. ;  make bottom := top + WHeight
  616.  
  617.             MOVE    Top(A0),D0            ; get top
  618.             ADD.W    D7,D0                ; add precomputed height            <29Aug85>
  619.             MOVE    D0,Bottom(A0)        ; update bottom
  620.             SUBQ    #1,Right(A0)        ; inset right
  621.             RTS                         ; return to caller
  622.  
  623. ; decide which icon needs hiliting
  624.  
  625. EORStuff    BEQ.S    EORGoAway            ; => it's the goAway                <EHB 29Aug85>
  626.             BSR     IsThereZoom         ; should we do zoom?                <EHB 29Aug85>
  627.             BEQ.S    NoGo                ; => no                             <EHB 29Aug85>
  628.  
  629. ; EORZoom hilites/unhilites the zoom button.  Falls into PlotZoom
  630.  
  631. EORZoom        BTST    #hasTallTBar,D6     ; does it have tall title bar?        <JKC 31Jul89>
  632.             BNE.S    @1                    ; => if so, skip to tall tbar stuff    <JKC 31Jul89>
  633.             BRA.S    InvertSmallZoom
  634.  
  635. @1             BSR.S    BuildTBarRect        ; build the bounding rect            <EHB 29Aug85>
  636.  
  637.             LEA     ZoomData+32,A1        ; get the zoom data                 <EHB 29Aug85>
  638.  
  639.             MOVEQ    #srcXOR,D0            ; set EOR as the plot mode            <EHB 29Aug85>
  640.  
  641. PlotZoom    LEA     TempRect,A0         ; start from titlebar rect            <EHB 29Aug85>
  642.             MOVE    right(A0),left(A0)    ; left := right-22                    <EHB 03Nov85>
  643.             MOVEQ    #-22,D1             ;                                    <EHB 03Nov85>
  644.             BRA.S    PlotIt                ; use common code to plot it        <EHB 29Aug85>
  645.  
  646. ; EORGoAway hilites/unhilites the goAway button.  It falls through into PlotGoAway
  647.  
  648. EorGoAway
  649.              BTST    #hasTallTBar,D6     ; does it have tall title bar?        <JKC 31Jul89>
  650.             BNE.S    @2                    ; => if so, skip to tall tbar stuff    <JKC 31Jul89>
  651.             BRA.S    InvertSmallGoAway
  652. @2            BSR.S    BuildTBarRect        ; build the bounding rect
  653.             LEA     GoAwayData+32,A1    ; get the bitMap
  654.             MOVEQ    #srcXOR,D0            ; set EOR as the plot mode
  655.  
  656. ; PlotGoAway plots the goAway button.  A1 holds the symbol, D1 the plotting mode
  657.  
  658. PlotGoAway
  659. ; make Temprect into a 16x16 square for our little bitmap
  660.  
  661.             LEA     TempRect,A0         ; point to temprect                     <5Aug85>
  662.             MOVEQ    #6,D1                ; add margin to left                    <5Aug85>
  663.  
  664. PlotIt        ADD.W    D1,left(A0)         ; add offset to left                   <29Aug85>
  665.             MOVE.W    WBoxDelta(A6),D1    ; get offset from top to GABox            <5Aug85>
  666.             ADD.W    D1,(A0)             ; add offset to top                     <5Aug85>
  667.             SUBQ.W    #1,(A0)             ; align bitmap                            <5Aug85>
  668.             MOVE.L    (A0)+,(A0)            ; bottom/right = top/left                <5Aug85>
  669.             MOVEQ    #16,D1                ; get a constant                        <5Aug85>
  670.             ADD.W    D1,(A0)+            ; Bottom = top + 16                     <5Aug85>
  671.             ADD.W    D1,(A0)             ; Right = Left + 16                     <5Aug85>
  672.  
  673.             MOVE.L    #$00100010,D1
  674.             BSR     PlotSymbol            ; plot it in tempRect
  675. NoGo        RTS
  676.             
  677. InvertSmallGoAway
  678.             BSR.S    BuildSmallGoAway
  679.             BSR.S    InsetInvert
  680.             RTS
  681.             
  682. DrawSmallGoAway
  683.             BSR.S    BuildSmallGoAway    ; get rect of goAway in TempRect        <JKC 31Jul89>
  684.             BSR.S    EraseInsetFrame
  685.             RTS
  686.  
  687. BuildSmallGoAway
  688.             BSR        BuildTBarRect
  689.             BSR.S    InsetByOneOne
  690.             LEA     TempRect,A0         ; point to temprect                     <JKC 31Jul89>
  691.             ADD.W    #6,Left(A0)            ; left is fixed at 6 from left edge        <JKC 31Jul89>
  692.             MOVE.W    Left(A0),D2            ; save left of TempRect                    <JKC 31Jul89>
  693.             ADD.W    #9,D2                ; new right = left + 9                    <JKC 31Jul89>
  694.             MOVE.W    D2,Right(A0)        ; new right of TempRect                    <JKC 31Jul89>
  695.             RTS
  696.             
  697. InvertSmallZoom
  698.             BSR.S    BuildSmallZoom
  699.             BSR.S    InsetInvert
  700.             RTS
  701.             
  702. DrawSmallZoom
  703.             BSR.S    BuildSmallZoom            ; get rect of zoom in TempRect        <JKC 31Jul89>
  704.             BSR.S    EraseInsetFrame
  705.             BSR.S    BuildSmallZoom
  706.             BSR.S    InsetByOneOne
  707.             LEA        TempRect,A0
  708.             SUB.W    #3,Right(A0)
  709.             SUB.W    #3,Bottom(A0)
  710.             MOVE.L    A0,-(SP)
  711.             _FrameRect
  712.             RTS
  713.             
  714. BuildSmallZoom
  715.             BSR        BuildTBarRect
  716.             BSR.S    InsetByOneOne
  717.             LEA     TempRect,A0         ; point to temprect                     <JKC 31Jul89>
  718.             SUB.W    #6,Right(A0)        ; right is fixed at 6 from right edge    <JKC 31Jul89>
  719.             MOVE.W    Right(A0),D2        ; save right of TempRect                <JKC 31Jul89>
  720.             SUB.W    #9,D2                ; new left = right - 9                    <JKC 31Jul89>
  721.             MOVE.W    D2,Left(A0)            ; new left of TempRect                    <JKC 31Jul89>
  722.             RTS    
  723.  
  724. InsetInvert
  725.             BSR.S    InsetByOneOne
  726.             PEA        TempRect            ; push address of TempRect                <JKC 31Jul89>
  727.             _InverRect                    ; and invert it                            <JKC 31Jul89>
  728.             RTS
  729.  
  730. EraseInsetFrame
  731.             PEA        TempRect            ; push address of TempRect                <JKC 31Jul89>
  732.             MOVE.L    (SP),-(SP)            ; make another copy of tempRect pointer    <JKC 31Jul89>
  733.             _EraseRect                    ; erase    the area around the box            <JKC 31Jul89>
  734.             BSR.S    InsetByOneOne
  735.             _FrameRect                    ; frame the go away box                    <JKC 31Jul89>
  736.             RTS
  737.  
  738. InsetByOneOne
  739.             PEA        TempRect
  740.             MOVE.L    OneOne,-(SP)        ; push inset factor                        <JKC 31Jul89>
  741.             _InsetRect
  742.             RTS
  743.             
  744. ; DoTitleString is the common code that draws the title centered in tempRect.  Warning --
  745. ; it trashes D3.  On exit, the left edge of the title's box is in D3 and
  746. ; the right edge is in D4.
  747.  
  748. DoTitleString
  749.  
  750. ; compute indent factor based on GoAwayButton state
  751.  
  752. @1            MOVE.W    TempRect+Right,D4    ; get right into D4         <EHB 18-Oct-85>
  753.             MOVE.W    D4,D3                ;                            <EHB 18-Oct-85>
  754.             SUB.W    TempRect+Left,D3    ; compute width
  755.             SUB.W    wTitleWidth(A3),D3    ; compute extra x
  756.             ASR.W    #1,D3                ; divide by 2
  757.  
  758. ; if the string is too long, position left edge
  759.  
  760.             MOVEQ    #2,D0                ; start title at x = 2        <16-May-85 EHB>
  761.             TST.B    WGoAway(A3)         ; is there a go away button <16-May-85 EHB>
  762.             BEQ.S    @2                    ; skip if there's not       <16-May-85 EHB>
  763.             MOVEQ    #32,D0                ; start title at x = 32     <16-May-85 EHB>
  764. @2            CMP.W    D0,D3                ; to left of x?             <16-May-85 EHB>
  765.             BGE.S    @3                    ; => no, D3 is ok            <16-May-85 EHB>
  766.             MOVE.W    D0,D3
  767. @3
  768.             ADD.W    TempRect+Left,D3    ; compute x position
  769.             MOVE.W    D4,-(SP)            ; save right across clip    <EHB 18-Oct-85>
  770.             BSR     IsThereZoom         ; is there a zoom box?        <EHB 18-Oct-85>
  771.             BEQ.S    @4                    ; => no, edge ok            <EHB 18-Oct-85>
  772.             SUB.W    #32,D4                ; get default right edge    <EHB 18-Oct-85>
  773. @4
  774. ; set clip to d3..d4
  775.  
  776.             MOVE.W    D4,TempRect+Right    ; set right for clipping    <EHB 18-Oct-85>
  777.             _OpenRgn                    ; open our clip region        <JKC 26Sep89>
  778.             PEA     TempRect            ; point to tempRect         <JKC 26Sep89>
  779.             _FrameRect                    ; frame title area            <JKC 26Sep89>
  780.             MOVE.L    ClpRgn(A6),-(SP)    ; get our clip region        <JKC 26Sep89>
  781.             _CloseRgn                    ; close it                    <JKC 26Sep89>
  782.  
  783.             MOVE.L    (A5),A0             ; get globals                <EHB 18-Oct-85>
  784.             MOVE.L    (A0),A0             ; get port                    <EHB 18-Oct-85>
  785.             MOVE.L    ClipRgn(A0),-(SP)    ; and the rect region        <EHB 18-Oct-85>
  786.             MOVE.L    ClpRgn(A6),-(SP)    ; get our clip region        <JKC 26Sep89>
  787.             MOVE.L    (SP),-(SP)            ; and use clip as dest        <EHB 18-Oct-85>
  788.             _SectRgn                    ; get the intersection        <EHB 18-Oct-85>
  789.  
  790.             MOVE.W    (SP)+,TempRect+Right    ; restore tempRect        <EHB 18-Oct-85>
  791.  
  792.             MOVE.W    D3,-(SP)            ; push left for MoveTo
  793.             MOVE.W    TempRect+Top,D0     ; get top                        <EHB 5Aug85>
  794.             ADD.W    WAscent(A6),D0        ; move down to baseline         <EHB 5Aug85>
  795.             ADDQ.W    #1,D0                ; leave 2 pixels white space    <EHB 7Aug85>
  796.             MOVE.W    D0,-(SP)            ; push baseline                 <EHB 5Aug85>
  797.             _MoveTo
  798.  
  799.             TST.B    IsColor(A6)            ; is it on a color system?    
  800.             BEQ.S    @NoColor6
  801.  
  802.             MOVE.W    #wTitleBarColor,D0    ; set up drawing colors
  803.             BSR        SetUpColor            ;
  804.             _RGBBackColor
  805.             MOVE.W    #wTextColor,D0        ;        
  806.             BSR        SetUpColor            ; 
  807.             _RGBForeColor                ;
  808.             
  809.             MOVE.W    #srcOR,-(SP)        ; set the mode to source OR        <C407/16Nov86> DAF
  810.             _TextMode                    ;                                <C407/16Nov86> DAF            
  811. @NoColor6                                ; END OF A COLOR ONLY SECTION
  812.  
  813. ; now calculate the size of the clear area needed for the title
  814. ; (only used if the window is highlighted).
  815.  
  816.             MOVE.W    D3,D0                ; left in D3, calc right in D0
  817.             SUBQ    #6,D3                ; indent to the left
  818.             ADD.W    wTitleWidth(A3),D0    ; add in the length             <EHB 18-Oct-85>
  819.             CMP.W    D4,D0                ; was title longer than space?    <EHB 18-Oct-85>
  820.             BGE.S    @5                    ; => yes, use D4                <EHB 18-Oct-85>
  821.             MOVE.W    D0,D4                ;                                <EHB 18-Oct-85>
  822. @5            ADD.W    #6,D4                ; indent on right                <EHB 18-Oct-85>
  823.             
  824.             MOVE.W    TempRect+Left,-(SP)    ; save left of TempRect            <JKC 20Sep89>
  825.             MOVE.W    D3,TempRect+Left    ; new left = title box left        <JKC 20Sep89>
  826.             MOVE.W    TempRect+Right,-(SP)    ; save right of TempRect    <JKC 20Sep89>
  827.             MOVE.W    D4,TempRect+Right    ; new right = title box right    <JKC 20Sep89>
  828.             PEA        TempRect            ; get title box rect            <JKC 20Sep89>
  829.             _EraseRect                    ; erase it                        <JKC 20Sep89>
  830.             MOVE.W    (SP)+,TempRect+Right    ; restore right of TempRect    <JKC 20Sep89>
  831.             MOVE.W    (SP)+,TempRect+Left    ; restore left of TempRect        <JKC 20Sep89>
  832.             
  833.             MOVE.L    TempRgn(A6),-(SP)    ; get our temp region            <EHB 18-Oct-85>
  834.             _GetClip                    ; and save for restore            <EHB 18-Oct-85>
  835.             MOVE.L    ClpRgn(A6),-(SP)    ; push the custom clip             <JKC 26Sep89>
  836.             _SetClip                    ; and set it                    <JKC 26Sep89>
  837.  
  838.             MOVE.L    wTitleHandle(A3),A0 ; get titleHandle
  839.             _HLock                        ; lock the title down            <C491/08Dec86> DAF
  840.             MOVE.L    (A0),-(SP)            ; push title pointer
  841.             _DrawString                 ; draw it
  842.             MOVE.L    wTitleHandle(A3),A0    ; get the handle again            <C491/08Dec86> DAF
  843.             _HUnlock                    ; release it                    <C491/08Dec86> DAF
  844.             
  845.             MOVE.L    TempRgn(A6),-(SP)    ; push the old clip             <EHB 18-Oct-85>
  846.             _SetClip                    ; and restore it                <EHB 18-Oct-85>
  847.  
  848.             RTS                         ; Left in D3, right in D4
  849.  
  850.  
  851. ; Snazzy new zoom data                                                    <JKC 25May89>                
  852.  
  853. ZoomData    DC.W    $5555,$0000,$3FF9,$2088                            ;    <stm 16oct89>
  854.             DC.W    $2089,$2088,$2089,$2088
  855.             DC.W    $3F89,$2008,$2009,$2008
  856.             DC.W    $3FF9,$0000,$5555,$0000
  857.  
  858. ; starburst mask
  859.             DC.W    $0000,$0000,$0000,$0180
  860.             DC.W    $09A0,$05C0,$0080,$1CF0
  861.             DC.W    $1F80,$0540,$0920,$0100
  862.             DC.W    $0000,$0000,$0000,$0000
  863.  
  864.  
  865. ; BitMap for default GoAway button
  866.  
  867. GoAwayData
  868.  
  869. ; This is the goAway Data                                            <JKC 25May89>
  870.  
  871.             DC.W    $AAAA,$0000,$9FFC,$1004
  872.             DC.W    $9004,$1004,$9004,$1004
  873.             DC.W    $9004,$1004,$9004,$1004
  874.             DC.W    $9FFC,$0000,$AAAA,$0000
  875.  
  876. ; starburst mask
  877.  
  878.            DC.W    $0000,$0000,$0000,$0080
  879.            DC.W    $0490,$02A0,$0000,$0E38
  880.            DC.W    $0000,$02A0,$0490,$0080
  881.            DC.W    $0000,$0000,$0000,$0000
  882.  
  883.  
  884. ;  Mask for goAway button (concentric squares)
  885.  
  886. ;             .WORD     $0000,$0000,$0000,$0000
  887. ;             .WORD     $0FE0,$0820,$0BA0,$0AA0
  888. ;             .WORD     $0BA0,$0820,$0FE0,$0000
  889. ;             .WORD     $0000,$0000,$0000,$0000
  890.  
  891. ; HitDoc -- perform a hit test on the document.  On entry, D3 contains the mousePoint
  892. ; in global coordinates while A3 holds the window pointer
  893.  
  894. HitDoc
  895.             CLR.W    -(SP)                ; make room for function result
  896.             MOVE.L    D3,-(SP)            ; push the mouse point
  897.             MOVE.L    CONTRGN(A3),-(SP)    ; push content region handle
  898.             _PtInRgn                    ; is the point in the content region?
  899.             TST.B    (SP)+                ; well, is it?
  900.             BEQ.S    NotInContent        ; if not, go check out drag region
  901.  
  902. ; it's in the content region -- see if it's in the grow icon area
  903.  
  904.             BTST    #hasGrow,D6         ; inGrow enabled?                   <EHB 29Aug85>
  905.             BGT.S    justContent         ; if not, skip
  906.  
  907.             TST.B    wHilited(A3)        ; is it active?
  908.             BEQ.S    justContent         ; if not, it cant be in grow
  909.  
  910.             MOVE.L    ContRgn(A3),A0        ; get region handle
  911.             MOVE.L    (A0),A0             ; get region ptr
  912.             MOVE.L    RgnBBox+botRight(A0),D0 ; get bottom left of content
  913.  
  914. ; first consider the x coordinate <16-May-85 EHB>
  915.  
  916.             MOVEQ    #14,D4                ; keep 14 in a register to save code
  917.  
  918.             SUB     D4,D0                ; offset x by 14
  919.             CMP     D0,D3                ; if <, just in content
  920.             BLT.S    justContent
  921.  
  922. ; its within range on x so try y
  923.  
  924.             SWAP    D0
  925.             SUB     D4,D0                ; check out y dimension
  926.             SWAP    D3
  927.             CMP     D0,D3                ; compare y coordinates
  928.             BLT.S    justContent
  929.  
  930.             MOVEQ    #wInGrow,D0         ; flag in grow Icon
  931.             BRA     DoneHitDoc
  932.  
  933. ; the point is in the content region so return a '1'
  934.  
  935. justContent
  936.             MOVEQ    #wInContent,D0        ; return in content
  937.             BRA      DoneHitDoc            ; go store function result and return
  938.  
  939. ; its not in the content -- see if its in the dragRgn (content extended by titleBar)
  940.  
  941. NotInContent
  942.  
  943.             BSR     BuildTBarRect        ; get the title bar rect into A0    <EHB 21-Oct-85>
  944.             CLR.W    -(SP)                ; make room for function result
  945.             MOVE.L    D3,-(SP)            ; push the mouse point
  946.             MOVE.L    A0,-(SP)            ; and push the rect                 <EHB 21-Oct-85>
  947.             _PtInRect                    ; is the point in the title bar?
  948.  
  949.             TST.B    (SP)+                ; examine result
  950.             BEQ        DoneHit1            ; if not, return 0 (do nothing)
  951.  
  952.             
  953.             BTST    #toggleTBar,D6         ; does the hilite state matter?        <JKC 27Sep89>
  954.             BEQ.S    @1                    ; no, test for goAway and zoom        <JKC 27Sep89>
  955.             TST.B    wHilited(A3)        ; is it hilited?
  956.             BEQ        ItsInDrag            ; if not, can't be in GoAway
  957.  
  958. ; test vertical for goAway and Zoom since they're the same
  959.  
  960. @1            MOVE.L    D3,D0                ; check vertical                <EHB 29Aug85>
  961.             SWAP    D0                    ; which is high word of D3        <EHB 29Aug85>
  962.             MOVE.L    A3,A0                ; convert the pointer if its a pixmap <C424/18Nov86> DAF
  963.             BSR        PortToMap            ; convert                        <C424/18Nov86> DAF
  964.             ADD.W    Bounds+Top(A0),D0    ; convert to local            <EHB 29Aug85>
  965.             SUB.W    PortRect+Top(A3),D0     ; compensate for origin     <EHB 29Aug85>
  966.  
  967.             ADD.W    WBoxDelta(A6),D0        ; below box?                <5Aug85>
  968.             BPL.S    ItsInDrag                ; => yes                    <5Aug85>
  969.             ADD.W    #11,D0                    ; in box?                    <5Aug85>
  970.             BMI.S    ItsInDrag                ; => no                     <5Aug85>
  971.  
  972.             TST.B    WGoAway(A3)         ; is there a goAway button?
  973.             BEQ.S    HitZoom             ; => no, hit-test zoom            <EHB 29Aug85>
  974.  
  975.             MOVE.L    D3,D0                ; get mousePt
  976.             ADD     Bounds+Left(A0),D0    ; convert to local (A0 still valid) <C424/18Nov86> DAF
  977.             SUB     PortRect+Left(A3),D0    ; compensate for origin
  978.             CMP     #18,D0                ; is it too far right for
  979.                                         ; either big or small?            <JKC 31Jul89>
  980.             BGT.S    HitZoom             ; if so, it's in drag            <EHB 29Aug85>
  981.              BTST    #hasTallTBar,D6     ; does it have tall title bar?    <JKC 31Jul89>
  982.             BNE.S    @2                    ; => yes, test left > 7            <JKC 31Jul89>
  983.             CMP     #16,D0                ; is it too far right?            <JKC 31Jul89>
  984.             BGT.S    HitZoom             ; if so, its in drag            <EHB 29Aug85>
  985.             BRA.S    @3                    ; it's in small goAway            <JKC 31Jul89>
  986. @2            SUBQ.W    #8,D0                ; it must be at least 7
  987.                                         ; to be in big goAway
  988.             BMI.S    ItsInDrag
  989.  
  990. ; its in the goAway button so signal it
  991.  
  992. @3            MOVEQ    #wInGoAway,D0
  993.             BRA.S    DoneHitDoc
  994.  
  995. HitZoom     BSR     IsThereZoom         ; is zooming permitted?         <EHB 29Aug85>
  996.             BEQ.S    ItsInDrag            ; => not in these here parts    <EHB 29Aug85>
  997.  
  998.             MOVE.W    D3,D0                    ; get mousePt                <EHB 29Aug85>
  999.             MOVE.L    A3,A0                    ; convert the pointer if its a pixmap <C424/18Nov86> DAF
  1000.             BSR        PortToMap                ; convert                    <C424/18Nov86> DAF
  1001.             ADD.W    Bounds+Left(A0),D0    ; convert to local                <EHB 29Aug85>
  1002.             SUB.W    PortRect+Right(A3),D0    ; make right edge = 0        <EHB 29Aug85>
  1003.             CMP.W    #-19,D0                 ; too far left for either
  1004.                                             ; big or small title bar?     <EHB 03Nov85>
  1005.             BLT.S    ItsInDrag                ; => if so, it's in drag    <EHB 29Aug85>
  1006.              BTST    #hasTallTBar,D6         ; does it have tall title bar?    <JKC 31Jul89>
  1007.             BNE.S    @4                        ; => yes, test for big zoom        <JKC 31Jul89>
  1008.             CMP.W    #-17,D0                    ; too far left for small zoom?    <JKC 31Jul89>
  1009.             BLT.S    ItsInDrag                ; => if so, it's in drag    <JKC 31Jul89>
  1010.             BRA.S    @5                        ; it's in small zoom        <JKC 31Jul89>
  1011.             
  1012. @4            CMP.W    #-9,D0                    ; too far right?            <EHB 03Nov85>
  1013.             BGT.S    ItsInDrag                ; => if so, it's in drag    <EHB 18Oct85>
  1014.  
  1015. @5            BSR     IsItSmall                ; is window big?            <EHB 29Aug85>
  1016.             BEQ.S    @1                        ; => oh boy, right again    <EHB 29Aug85>
  1017.             MOVEQ    #wInZoomOut,D0            ; say window small            <EHB 29Aug85>
  1018.             BRA.S    DoneHitDoc                ; und scram-muller            <EHB 29Aug85>
  1019.  
  1020. @1            MOVEQ    #wInZoomIn,D0            ; say window big            <EHB 29Aug85>
  1021.             BRA.S    DoneHitDoc                ; and muller out of here    <EHB 29Aug85>
  1022.  
  1023. ItsInDrag    MOVEQ    #wInDrag,D0         ; flag in drag region
  1024.  
  1025. DoneHitDoc    MOVE.L    D0,20(A6)            ; update function result
  1026.  
  1027. DoneHit1    RTS
  1028.  
  1029.  
  1030. ; CalcDoc  -- calculate the structure and content regions for the window pointed
  1031. ; to by A3.  First update size for zooming if necessary
  1032.  
  1033. CalcDoc     BSR     IsThereZoom         ; zoom feature enabled?         <EHB 29Aug85>
  1034.             BEQ.S    @1                    ; => no                         <EHB 29Aug85>
  1035.             BSR     IsItSmall            ; update window size            <EHB 29Aug85>
  1036. @1
  1037.             LEA     TEMPRECT,A0         ; get a pointer to the work rectangle
  1038.             MOVE.L    A0,-(SP)            ; push for later offset
  1039.             MOVE.L    PORTRECT(A3),(A0)+    ; copy topLeft of portRect
  1040.             MOVE.L    PORTRECT+4(A3),(A0) ; copy botLeft of portRect
  1041.  
  1042. ; offset it to global coordinates
  1043.  
  1044.             MOVE.L    A3,A0                ; convert the pointer if its a pixmap <C424/18Nov86> DAF
  1045.             BSR        PortToMap            ; convert                        <C424/18Nov86> DAF
  1046.             MOVE.L    BOUNDS(A0),-(SP)    ; push topLeft of port.portBits.bounds <C424/18Nov86> DAF
  1047.             NEG     0(SP)                ; negate offset
  1048.             NEG     2(SP)                ; both words
  1049.             _OffsetRect                 ; offset tempRect to global coordinates
  1050.  
  1051. ;  make the rectangular content region
  1052.  
  1053.             MOVE.L    CONTRGN(A3),-(SP)    ; content region gets the result
  1054.             PEA     TempRect            ; tempRect is the rectangle
  1055.             _RectRgn                    ; go make the region into content region
  1056.  
  1057. ; now do the structure region.    First correct the bounding rectangle (tempRect) for
  1058. ; structure instead of content
  1059.  
  1060.             MOVE.L    #$00020002,D4        ; get the shadow factor for DBox
  1061.             MOVE.L    STRUCTRGN(A3),-(SP) ; push the structRgn for later
  1062.             PEA     TEMPRECT            ; push a pointer to the rect
  1063.             MOVE.L    (SP),-(SP)            ; make two copies
  1064.             MOVE.L    MinusOne,-(SP)        ; make 1 pixel bigger, all around
  1065.             _InsetRect                    ; make it bigger
  1066.  
  1067.             MOVE.W    D7,D0                ; move up to top of window                <29Aug85>
  1068.             SUBQ.W    #1,D0                ; tweak it                                <5Aug85>
  1069.             SUB.W    D0,TempRect+Top     ; and set top of struct region            <5Aug85>
  1070.  
  1071.             LSR.L    #1,D4                ; adjust shadow factor
  1072. CalcCommon
  1073.             _RectRgn                    ; RectRgn(structRgn,tempRect)
  1074.  
  1075. ; now add in the 1 or 2 pixel drop shadow
  1076.  
  1077. ;;The next block (marked with ";;") was commented out by Chris Knepper on 10-Oct-90
  1078. ;;            TST.B    IsColor(A6)            ; are we on a multi-bit Mac?
  1079. ;;            BEQ.S    NormShadow            ; if not, then do normal shadows
  1080. ;;            
  1081. ;;            ADD.L    D4,TempRect+botright ; increase rect by shadow size
  1082. ;;            MOVE.L    StructRgn(A3),-(SP)    ; push the regionHandle
  1083. ;;            PEA        TempRect            ; and the rect
  1084. ;;            _RectRgn                    ; and set it
  1085. ;;            BRA.S    CommShadow            ; and continue
  1086. ;;NormShadow
  1087. ;;
  1088.             MOVE.L    TempRgn(A6),-(SP)    ; get temp region                    <EHB 18Oct85>
  1089.             PEA     TempRect            ; push tempRect
  1090.             MOVE.L    (SP),-(SP)            ; save another copy
  1091.             MOVE.L    D4,-(SP)            ; push shadow factor
  1092.             _OffsetRect                 ; offset it
  1093.             _RectRgn
  1094.  
  1095.             MOVE.L    StructRgn(A3),-(SP)
  1096.             MOVE.L    TempRgn(A6),-(SP)    ; get temp region                    <EHB 18Oct85>
  1097.             MOVE.L    StructRgn(A3),-(SP) ; structure gets the result
  1098.             _UnionRgn                    ; add it in
  1099. CommShadow
  1100.  
  1101. ; all done with CalcDocRgns
  1102.  
  1103. NoDropShadow
  1104.             RTS
  1105.  
  1106.  
  1107. ; GrowDoc handles the grow message by drawing a grow outline based on the rectangle
  1108. ; passed in D3
  1109.  
  1110. GrowDoc
  1111.  
  1112. ; first make it one pixel bigger to jibe with the structure
  1113.  
  1114.             MOVE.L    D3,-(SP)            ; push the rect
  1115.             MOVE.L    MinusOne,-(SP)        ; push (-1,-1)
  1116.             _InsetRect
  1117.             MOVE.L    D3,A3                ; get rect ptr
  1118.             MOVE.L    Top(A3),-(SP)        ; save topleft for below            <5Aug85>
  1119.             MOVE.W    D7,D0                ; adjust for title                    <29Aug85>
  1120.             SUB.W    #1,D0                ; and tweak it                        <5Aug85>
  1121.             SUB.W    D0,Top(A3)            ; and save it                        <5Aug85>
  1122.  
  1123.             MOVE.L    D3,-(SP)            ; push the rectangle
  1124.             _FrameRect                    ; frame it
  1125.  
  1126. ;  now that the rectangle is drawn, draw the lower horizontal line
  1127.  
  1128.             MOVE.W    Left(A3),-(SP)        ; push left
  1129.             MOVE.W    Bottom(A3),-(SP)    ; push bottom
  1130.             SUB     #16,(SP)            ; really 16 pixels above bottom
  1131.             MOVE.L    (SP),-(SP)            ; make a copy of this point
  1132.             _MoveTo                     ; move to it
  1133.             MOVE.W    Right(A3),2(SP)     ; now go to the right edge
  1134.             _LineTo                     ; draw the horizontal line
  1135.  
  1136. ; draw the upper horizontal line
  1137.  
  1138.             MOVE.L    (SP),Top(A3)        ; restore topLeft, leave on stack    <5Aug85>
  1139.             MOVE.L    (SP),-(SP)            ; make a copy of this point
  1140.             _MoveTo                     ; move to it
  1141.             MOVE.W    Right(A3),2(SP)     ; now go to the right edge
  1142.             _LineTo                     ; draw the horizontal line
  1143.  
  1144. ; draw the vertical line
  1145.  
  1146.             MOVE.W    Right(A3),-(SP)     ; push right
  1147.             SUB     #16,(SP)            ; really want right - 16
  1148.             MOVE.W    Top(A3),-(SP)        ; push top
  1149.             MOVE.L    (SP),-(SP)            ; make a copy of this point
  1150.             _MoveTo                     ; and move to it
  1151.             MOVE.W    Bottom(A3),(SP)     ; now go to bottom edge
  1152.             _LineTo                     ; draw the vertical line
  1153.  
  1154. ; restore the rect back to how it was when we got it
  1155.  
  1156.             MOVE.L    D3,-(SP)            ; push the rect
  1157.             MOVE.L    OneOne,-(SP)        ; push (1,1)
  1158.             _InsetRect
  1159.             RTS                         ; all done!
  1160.  
  1161. ;  Utility PaintDropShadow -- drop shadows the rectangle in A4, by the amount in D4
  1162.  
  1163. PaintDropShadow
  1164.             MOVE.L    D4,-(SP)            ; push shadow factor
  1165.             _PenSize                    ; make penSize = shadow factor
  1166.  
  1167.             MOVE    RIGHT(A4),D0        ; get right of menuRect
  1168.             MOVE    D0,-(SP)            ; push right
  1169.             MOVE    TOP(A4),-(SP)        ; push top
  1170. ;            IF not SquareWind THEN            ;                     <C203/06Oct86> DAF
  1171.                 ADD     D4,(SP)             ; want top+shadow
  1172. ;            ENDIF                            ;                     <C203/06Oct86> DAF
  1173.             MOVE    D0,-(SP)            ; push right
  1174.             MOVE    BOTTOM(A4),D0        ; get bottom
  1175.             MOVE    D0,-(SP)            ; push bottom
  1176.             MOVE    LEFT(A4),-(SP)        ; push left
  1177. ;            IF not SquareWind THEN            ;                     <C203/06Oct86> DAF
  1178.                 ADD     D4,(SP)             ; want left+shadow
  1179. ;            ENDIF                            ;                     <C203/06Oct86> DAF
  1180.             MOVE    D0,-(SP)            ; push bottom
  1181.  
  1182. ;;            TST.B    IsColor(A6)            ; are we on a multi-bit Mac?
  1183. ;;            BNE.S    NOffSh                ; if so, then don't offset shadow
  1184. ;;            TST.W    D5                    ; 
  1185. ;;            BEQ.S    NOffSh                ;
  1186.             
  1187. ; adjust shadow line ends            
  1188.             
  1189. ;;            ADD        D4,2(SP)            ; want left+shadow
  1190. ;;            ADD        D4,8(SP)            ; want top+shadow
  1191.                         
  1192. NOffSh
  1193.  
  1194. ; colors are OK here
  1195.  
  1196.             _MoveTo                     ; MoveTo(left+shadow,bottom)
  1197.             _LineTo                     ; LineTo(right,bottom)
  1198.             _LineTo                     ; LineTo(right,top+shadow)
  1199.  
  1200.             _PenNormal                    ; restore normal pen
  1201.             RTS
  1202.  
  1203.  
  1204. ;  PlotSymbol -- plot the little 16 by 16 symbol bitmap pointed to by A1 into the rectangle
  1205. ;  pointed held in TempRect. D0 holds the mode.
  1206. ;  Plot Symbol plots an 8 by 8 symbol if the window has a short title bar.
  1207.  
  1208. PlotSymbol
  1209.             LEA     IconBitMap,A0        ; get pointer to source bitmap
  1210.             MOVE.L    A1,(A0)+            ; update base address of bitMap
  1211.             MOVE    #2,(A0)+            ; update rowBytes
  1212.             CLR.L    (A0)+                ; topLeft is zero, zero
  1213.             MOVE.L    D1,(A0)             ; adjust boundsRect
  1214.  
  1215. ; push parameters for CopyBits call to transfer arrow bitMap
  1216.  
  1217.             PEA     IconBitMap            ; push pointer source bitmap
  1218.             MOVE.L    (SP),A0             ; remember in A0, too
  1219.             MOVE.L    GrafGlobals(A5),A1    ; get lisaGraf global baseaddress
  1220.             MOVE.L    THEPORT(A1),A1        ; get thePort
  1221.             PEA     PORTBITS(A1)        ; that's the destination bitmap
  1222.  
  1223.             PEA     BOUNDS(A0)            ; boundsRect of bitmap is source
  1224.             PEA     TempRect            ; tempRect is the destination
  1225.             MOVE.W    D0,-(SP)            ; theMode is in D0
  1226.             CLR.L    -(SP)                ; no mask region
  1227.  
  1228. ; the colors should be OK here                                        <DAF 16-Apr-86>
  1229.  
  1230. ; transfer the bitMap (stretching as necessary...)
  1231.  
  1232.             _CopyBits                    ; let Bill stretch those bits
  1233.  
  1234.             RTS                         ; return to caller
  1235.  
  1236.  
  1237.  
  1238. ;  Draw the grow icon.    First make this window the current grafPort
  1239.  
  1240. DrawGIcon
  1241.             MOVE.L    GrafGlobals(A5),A0    ; get the current port and save it <C203> DAF
  1242.             MOVE.L    thePort(A0),-(SP)    ;                                   <C203> DAF
  1243.             
  1244.             MOVE.L    A3,-(SP)            ; push the window's port
  1245.             _SetPort                    ; make that the port
  1246.             
  1247.             
  1248. ; save the foreground and background of the user port & set new colors    <DAF 16-Apr-86>
  1249.  
  1250.             TST.B    IsColor(A6)            ; is this a color system?
  1251.             BEQ.S    @NoColor7            ; nope, so skip this stuff
  1252.             
  1253.             SUBQ    #6,SP                ; make room for rgbColor on stack    <C???/11Jan87> DAF
  1254.             MOVE.L    SP,-(SP)            ; push pointer to placeholder        <C???/11Jan87> DAF
  1255.             _GetForeColor                ; get the window port's foreColor    <C???/11Jan87> DAF
  1256.             
  1257.             SUBQ    #6,SP                ; make room for the backColor too    <C???/11Jan87> DAF
  1258.             MOVE.L    SP,-(SP)            ; push pointer to placeholder        <C???/11Jan87> DAF
  1259.             _GetBackColor                ; get the window port's backColor    <C???/11Jan87> DAF
  1260.  
  1261.             MOVE.W    #wContentColor,D0    ; get the drawing color
  1262.             BSR        SetUpColor            ; 
  1263.             _RGBBackColor                ;                                    <C117/25Sep86> DAF
  1264.  
  1265.             MOVE.W    #wFrameColor,D0        ;
  1266.             BSR        SetUpColor            ;
  1267.             _RGBForeColor                ;                                    <C117/25Sep86> DAF
  1268. @NoColor7                                ; END OF COLOR-ONLY SECTION
  1269.  
  1270. ;  compute the grow icon rectangle in tempRect
  1271.  
  1272.             LEA     TempRect,A4         ; get pointer to tempRect
  1273.             MOVE.L    PortRect+4(A3),4(A4)    ; copy in botRight of tempRect
  1274.             MOVE.L    4(A4),(A4)            ; into the topLeft, too
  1275.             SUB.W    #15,Top(A4)
  1276.             SUB.W    #15,Left(A4)        ; and left, too
  1277.  
  1278. ; plot the grow icon
  1279.  
  1280.             TST.B    wHilited(A3)        ; is it hilited?
  1281.             BEQ.S    ClearGoAway         ; if not, go clear it
  1282.  
  1283.             LEA     GrowBits,A1         ; get pointer to the bits
  1284.             MOVEQ    #0,D0                ; use srcCopy
  1285.             MOVE.L    #$00100010,D1
  1286.             BSR      PlotSymbol            ; plot it
  1287.  
  1288. ; plot the    boundary lines
  1289.  
  1290. PlotBoundary
  1291.             MOVE.W    Left(A4),-(SP)        ; push tempRect.left
  1292.             MOVE.W    (SP),-(SP)            ; copy it again for later
  1293.             MOVE    PortRect+Top(A3),-(SP)    ; push portRect.top
  1294.             _MoveTo                     ; move to it
  1295.             MOVE    PortRect+Bottom(A3),-(SP)    ; push portRect.bottom
  1296.             _LineTo                     ; draw the vertical line
  1297.  
  1298. ; now draw the horizontal line
  1299.  
  1300.             MOVE.W    PortRect+Left(A3),-(SP) ; push portRect.left
  1301.             MOVE.W    Top(A4),-(SP)        ; push tempRect.top
  1302.             _MoveTo
  1303.             MOVE.W    PortRect+right(A3),-(SP)    ; push portRect.right
  1304.             MOVE.W    Top(A4),-(SP)        ; push tempRect.top
  1305.             _LineTo
  1306.  
  1307. ; all done with DrawDocGrow
  1308.  
  1309. DoneDDG
  1310.             TST.B    IsColor(A6)            ; is it a color system?
  1311.             BEQ.S    @NoColor8            ; no, so skip this restore
  1312.             
  1313.             MOVE.L    SP,-(SP)            ; push ptr to rgbColor previously saved on top of stack     <C117/25Sep86> DAF    
  1314.             _RGBBackColor                ;                                 <C117/25Sep86> DAF    
  1315.             ADDQ    #6,SP                ; trash backcolor                <C117/25Sep86> DAF    
  1316.             MOVE.L    SP,-(SP)            ;                                 <C117/25Sep86> DAF    
  1317.             _RGBForeColor                ;                                <C117/25Sep86> DAF    
  1318.             ADDQ    #6,SP                ;                                <C117/25Sep86> DAF    
  1319. @NoColor8                                ; END OF A COLOR-ONLY SECTION
  1320.         
  1321.             _SetPort                    ; restore the incoming port (saved above) <C203> DAF
  1322.                                         
  1323.             RTS
  1324.  
  1325. ClearGoAway
  1326.             PEA     TempRect
  1327.             _EraseRect
  1328.             BRA.S    PlotBoundary
  1329.  
  1330.  
  1331. ; BitMap for GrowIcon
  1332.  
  1333. GrowBits
  1334.             DC.W    $0000,$0000,$0000,$1FE0
  1335.             DC.W    $1020,$103E,$1022,$1022
  1336.             DC.W    $1022,$1022,$1FE2,$0402
  1337.             DC.W    $0402,$0402,$07FE,$0000
  1338.  
  1339.             END 
  1340.  
  1341. ; end of Window DefProc #3